/*
 * @文件描述: ADC前端调理电路参数设置，及触发电路驱动头文件
 * @版本:
 * @作者: 周晨阳
 * @Date: 2021-01-16 00:15:34
 */
#ifndef ADC_CONDITIONING_H
#define ADC_CONDITIONING_H
#include "DAC.h"
#include "public.h"
#include "EXIT.h"
#ifndef WIN_SIM
#include "stm32f4xx.h"
#define _4051_A_PIN GPIO_Pin_0
#define _4051_A_PORT GPIOC
#define _4051_A_CLK RCC_AHB1Periph_GPIOC

#define _4051_B_PIN GPIO_Pin_1
#define _4051_B_PORT GPIOC
#define _4051_B_CLK RCC_AHB1Periph_GPIOC

#define _4051_C_PIN GPIO_Pin_15
#define _4051_C_PORT GPIOB
#define _4051_C_CLK RCC_AHB1Periph_GPIOB

#define RELAY_PIN GPIO_Pin_7
#define RELAY_PORT GPIOC
#define RELAY_CLK RCC_AHB1Periph_GPIOC
#endif
#define VERTI_GAIN_1 1
#define VERTI_GAIN_2 2
#define VERTI_GAIN_5 3
#define VERTI_GAIN_10 4
#define VERTI_GAIN_20 5
#define VERTI_GAIN_50 6
#define VERTI_GAIN_100 7
#define VERTI_GAIN_200 8

//实际衰减为11倍
#define DAMPING_FACTOR_10 1
//实际衰减为1.1倍
#define DAMPING_FACTOR_1 2

//初始化
void ADC_Condition_Init(void);
//设置放大器增益
void setAmpGain(uint8_t gain);
uint8_t getAmpGain(void);
//设置衰减器倍数
void setDampFactor(uint8_t factor);
uint8_t getDampFactor(void);
//设置触发电平
void setTrigVoltage(float voltage);
float getTrigVoltage(void);
//设置触发方式
void setTrigMethod(uint8_t method);
//设置当触发信号到来时，需要被调用的函数，
//第一个参数为是上升沿触发还是下降沿触发，第二个参数为触发电压
void setTrigCallback(void (*callback)(uint8_t, float));
float getActualTrigVoltage(float voltage);
#endif